
import { useState,useContext,createContext,useEffect } from "react";
import axios from 'axios';
// 项目根组件
function GetUseEffect() {
    const menuName = "通过请求获取菜单数据";
    const [datalist, setMenuList] = useState([])
    useEffect(()=>{
        axios.get('http://localhost:3004/commentList').then(res=>{
            console.log(res)
            setMenuList(res.data)
    })},[])
 
  return (
    <div className="">
      <h2>{menuName}</h2>
      <ul>
        {datalist.map((item,index) => (
          <li key={index}>
                <div>
                    <span>{item.name}:</span>  <span>{item.content}</span>
                    <p>
                        <span>{item.date}</span>  <span> 赞:{item.zan}</span> 
                    </p>
                </div>
            </li>
        ))}
      </ul>
    </div>
   
  );
}


export default GetUseEffect;
